<template>
  <div class="tab-control">
      <div class="tab-control-item" v-for="title,index in titles" :key="title" @click="changeCurrr(index)">
          <span :class="{active:index==currIndex}">{{title}}</span>
      </div>
  </div>
</template>

<script type="text/ecmascript-6">
export default {
  name: "TabControl",
  data() {
    return {
        currIndex:0
    };
  },
  components: {},
  methods:{
      changeCurrr(index){
          this.currIndex = index;
      }
  },
  props:{
     titles:{
         type:Array,
         default(){
             return [];
         }
     } 
  }
};
</script>

<style scoped>
.tab-control{
    display: flex;
    text-align: center;
    height: 40px;
    line-height: 40px;
    font-size: 15px;
    background-color: #fff;
}
.tab-control-item{
    flex: 1;
}
.tab-control-item span{
    padding: 5px;
}
.active{
    color: red;
    border-bottom: 3px solid red;
}

</style>
